<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="86px">
      <el-form-item label="实验室编号" prop="sampleName">
        <el-input
          v-model="queryParams.sampleName"
          placeholder="请输入实验室编号编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="血片编号" prop="bpnName">
        <el-input
          v-model="queryParams.bpnName"
          placeholder="请输入血片编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table ref="multipleTable" v-loading="loading" :data="bpnList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" />
      <el-table-column label="血片编号" align="center" prop="bpnName" />
      <el-table-column label="实验室编号" align="center" prop="sampleName" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="状态" align="center" prop="status" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.his_bpn_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>

  </div>
</template>

<script>
import { listBpn} from "@/api/his/bpn";
import { getUserProfile } from '@/api/system/user'

export default {
  props: {
    value: {
      type: Number,
      default: ''
    }
  },
  dicts: ['his_bpn_status'],
  name: "Bpn",
  data() {
    return {
      textToTranslate:'',
      // 遮罩层
      loading: true,
      //选中的血片编号
      checkedGh: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 血片编号表格数据
      bpnList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deptId: null,
        bpnName: null,
        sampleName:null,
        orderNum: null,
        leader: null,
        status: null,
      },
      // 表单参数
      form: {},
      selectOptions:{
        status:[]
      }
    };
  },
  created() {
    //console.log(this.value,'this.value')
    this.getUser();
    this.getList();
  },
  methods: {
    /** 查询血片编号列表 */
    getList() {
      this.loading = true;
      this.queryParams.status = 0;
      this.queryParams.deptId = this.value
      listBpn(this.queryParams).then(response => {
        this.bpnList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 单选框选中数据
    handleSelectionChange(selection) {
      this.checkedGh = selection[0];
      if (selection.length > 1) {
         this.$refs.multipleTable.clearSelection();
         this.$refs.multipleTable.toggleRowSelection(selection.pop());
      }

      this.$emit('formSubmit', this.checkedGh); //父组件监听的名字必须是formSubmit
    },
    getUser() {
      getUserProfile().then(response => {
        this.queryParams.deptId = response.data.dept.deptId;
      });
    },
  }
};
</script>
